#ifndef VIEWMODELSUBJECT_H
#define VIEWMODELSUBJECT_H

#include <QDebug>
#include "../base/baseviewmodelmanager.h"

/**
 * @brief The Subject class
 * ViewModel充当被观察者时，继承该类
 */
class ViewModelSubject
{
public:
    ViewModelSubject(BaseViewModelManager* manager):m_manager(manager){}
    /**
     * @brief 用于唤醒观察改类的观察者的函数，会调用观察者的update函数
     * @param nextViewModelName
     */
    virtual void notify(const std::string& nextViewModelName){
        if(m_manager == nullptr){
            qDebug() << "ViewModelSubject's m_manager is nullptr";
        }
        m_manager->update(nextViewModelName);
    }

    virtual ~ViewModelSubject(){}
protected:
    BaseViewModelManager* m_manager;
};

#endif // VIEWMODELSUBJECT_H
